const path = require("path");
const htmlWebpackPlugin = require("html-webpack-plugin");
const { merge } = require("webpack-merge");
const baseConfig = require("./webpack.base.js");
const webpack = require("webpack");
const devConfig = {
  mode: "development",
  devtool: "inline-source-map",
  module: {
    rules: [
      {
        test: /\.less$/,
        include: path.resolve(__dirname, "./src/css"),
        use: ["style-loader", "css-loader", "postcss-loader", "less-loader"],
      },
    ],
  },
  devServer: {
    contentBase: "./dist",
    port: 8081,
    open: true,
    hot: true,
    proxy: {
      "/api": {
        target: "http://localhost:9092",
      },
    },
    //不自动刷新浏览器窗口
    hotOnly: true,
  },
  plugins: [
    new htmlWebpackPlugin({
      template: "./src/index.html",
      filename: "index.html",
    }),
    new webpack.HotModuleReplacementPlugin(),
  ],
};

module.exports = merge(baseConfig, devConfig);
